

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:gczn_hd/app/core/base/handle_mixin.dart';
import 'package:gczn_hd/app/core/values/app_colors.dart';
import 'package:gczn_hd/app/core/values/app_values.dart';
import 'package:gczn_hd/app/core/widget/custom_title_bar.dart';

import '../../../../core/values/text_styles.dart';

class TaskAwaiting extends StatelessWidget with HandleMixin{



  @override
  Widget build(BuildContext context) {

    return  Container(
        padding: EdgeInsets.only(top: AppValues.size28.h, left: AppValues.size30.w, right: AppValues.size30.w, bottom: AppValues.size28.h),
        decoration: BoxDecoration(
          border: Border.all(
            color: const Color.fromRGBO(39, 65, 80, 1),
            width: 1.0,
          ),
          borderRadius: BorderRadius.circular(AppValues.margin_12.r),
          color: AppColors.gcznPrimaryColor,
        ),
        child: Column(
          children: [
            const CustomTitleBar(title: "待产任务(4)"),
            SizedBox(height: AppValues.size28.h,),
            _buildGrid( context)
          ],
        ),
      );
  }
}

Widget _buildGrid(BuildContext context){
  final List<Map<String, String>> gridItems = [
    {'title': 'QA', 'subtitle': '检验',"isDisable": '0'},
    {'title': 'QC', 'subtitle': '检验', "isDisable": '1'},
    {'title': '生产', 'subtitle': '报工', "isDisable": '0'},
    {'title': '查看', 'subtitle': 'SOP', "isDisable": '0'},
    {'title': '查看', 'subtitle': 'SOP', "isDisable": '0'},
  ];
  const double itemHeight = 178;

  return Wrap(
    spacing: AppValues.margin_10, // 水平间距
    runSpacing: AppValues.margin_10, // 垂直间距
    children: gridItems.map((item) {
      return GestureDetector(
        onTap: () {
          // TODO
        },
        child: Container(
          width: (MediaQuery.of(context).size.width - 3 * AppValues.margin_10 - AppValues.size60) / 5, // 计算每个子项的宽度
          // height: itemHeight.h,
          padding: EdgeInsets.only(bottom: 5),
          decoration: BoxDecoration(
            border: Border.all(
              color: const Color.fromRGBO(39, 65, 80, 1),
              width: 1.0,
            ),
            borderRadius: BorderRadius.circular(AppValues.margin_12.r),
            color: AppColors.processBtn,
            boxShadow: const [pressShadow],
          ),
          child: Container(
            padding: EdgeInsets.only(left: AppValues.iconSize_14.w, right: AppValues.iconSize_14.w, top: AppValues.size12.h, bottom: AppValues.size12.h),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.start,
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text("任务单号：GD10293", maxLines: 1, overflow: TextOverflow.ellipsis, style: textStyle20),
                SizedBox(height: AppValues.size14.h,),
                Text("计划产品：马克杯001马克杯001马克杯001马克杯001", maxLines: 1, overflow: TextOverflow.ellipsis, style: textStyle20Opa),
                Text("计划产量：1000个", maxLines: 1, overflow: TextOverflow.ellipsis, style: textStyle20Opa),
                Text("计划开始：2024-1-12", maxLines: 1, overflow: TextOverflow.ellipsis, style: textStyle20Opa),
                Text("计划交期：2024-1-30（剩余7天）", maxLines: 1, overflow: TextOverflow.ellipsis, style: textStyle20Opa),

              ],
            ),
          ),
        ),
      );
    }).toList(),
  );
}